package cn.yunhe.servlet;

import cn.yunhe.dao.IUserAccount;
import cn.yunhe.entity.userentity.UserAccount;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;



/**
 * 王羊
 * 异步
 * 手机号
 */
@WebServlet("/SearchUserByTelServlet")
public class SearchUserByTelServlet extends HttpServlet {
    SqlSession Sqlsession =null;
            IUserAccount iUserAccount =null;
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try{
            Sqlsession = SqlSessionFactoryUtil.getSqlSession();
            iUserAccount = Sqlsession.getMapper(IUserAccount.class);
            String tel = request.getParameter("tel");

            UserAccount userAccount = iUserAccount.denglu6(tel);

            PrintWriter out = response.getWriter();
            if ("".equals(tel)||tel==null){
                out.print("kong");
            }else {


            if (userAccount != null) {

                out.print("true");
            } else {
                out.print("false");
            }
            }
        }finally {
            Sqlsession.close();
        }

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

}
